import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useCustomerStore = defineStore('customer', () => {
  const store = ref<any>(null) // 当前选择的门店

  const setStore = (s: any) => {
    store.value = s
    localStorage.setItem('customerStore', JSON.stringify(s))
  }

  const loadStore = () => {
    const cached = localStorage.getItem('customerStore')
    if (cached) store.value = JSON.parse(cached)
  }

  return { store, setStore, loadStore }
})